<template>
  <div style="margin: 20px 30px; height: 100%">
    <el-tabs v-model="activeName" @tab-click="handleClick(activeName)">
      <!-- <el-tab-pane  :key="bargain" label="砍价" name="bargain">
        <selectInfo v-if="isBargain  " :selectType="selectType" :result="result">
        </selectInfo>
      </el-tab-pane>
      <el-tab-pane  :key="limittime" label="限时" name="limittime">
        <selectInfo v-if=" isLimittime  " :selectType="selectType" :result="result">
        </selectInfo>
      </el-tab-pane> -->
    </el-tabs>
  </div>
</template>
<script>
import { getInfo } from "@/api/activity/info";
import selectInfo from "./selectInfo.vue";
export default {
  components: {
    selectInfo,
  },
  data() {
    return {
      isBargain: false,
      isSeckill: false,
      isLimittime: false,
      isGroup: false,
      isFree: false,
      isPackages: false,
      isScore: false,
      activeName: "bargain",
      payPatternUpdate: false,
      activeData: [
        { activityType: "bargain", activityName: "砍价" },
        { activityType: "seckill", activityName: "秒杀" },
        { activityType: "limittime", activityName: "限时" },
        { activityType: "group", activityName: "拼团" },
        { activityType: "free", activityName: "新人免费领" },
        { activityType: "packages", activityName: "套餐" },
        { activityType: "score", activityName: "积分兑换" },
      ],
      result: null,
      selectType: { activityType: "bargain", activityName: "砍价" },
    };
  },
  created() {
    const activityUid = this.$route.params && this.$route.params.activityUid;
    if (activityUid) {
      getInfo(activityUid).then((response) => {
        console.log(this.result);
        this.result = response.data;
        this.activeName = this.result.activityType;
        this.handleClick(this.activeName, this.result);
      });
    } else {
      this.handleClick(this.activeName);
    }
  },
  methods: {
    handleClick(activeName, result) {
      console.log(activeName);
      console.log(result);
      this.reset();
      switch (activeName) {
        case "bargain":
          this.isBargain = true;
          this.selectType = { activityType: "bargain", activityName: "砍价" };
          break;
        case "seckill":
          this.isSeckill = true;
          this.selectType = { activityType: "seckill", activityName: "秒杀" };
          break;
        case "limittime":
          this.isLimittime = true;
          this.selectType = { activityType: "limittime", activityName: "限时" };
          break;
        case "group":
          this.isGroup = true;
          this.selectType = { activityType: "group", activityName: "拼团" };
          break;
        case "free":
          this.isFree = true;
          this.selectType = {
            activityType: "free",
            activityName: "新人免费领",
          };
          break;
        case "packages":
          this.isPackages = true;
          this.selectType = { activityType: "packages", activityName: "套餐" };
          break;
        case "score":
          this.isScore = true;
          this.selectType = { activityType: "score", activityName: "积分兑换" };
          break;
      }
    },
    reset() {
      this.isBargain = false;
      this.isSeckill = false;
      this.isLimittime = false;
      this.isGroup = false;
      this.isFree = false;
      this.isPackages = false;
      this.isScore = false;
    },
  },
};
</script>
